﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;

using ProjectBase.Core;

namespace $safeprojectname$
{
    /// <summary>
    ///     base implementator of ICodeList represents almost unchanging set of values.
    ///     E.g. Countries, Currencies, Types, Colors.
    ///     In comparison with Enum they are more likely objects - entities
    ///     with uniqe Code and more describing Name.
    ///     Due to their state, ICodeLists are easy to localize
    ///     and therefore used on UI with approprieate user language dependent value
    /// </summary>
    [Serializable]
    public class CodeList : Persistent<int>, ICodeList
    {
        public virtual string Code { get; set; }

        /// <summary>
        ///     Description of the value
        /// </summary>
        public virtual string Description { get; set; }

        /// <summary>
        /// Should be value displayed? Should be contained in ComboBox
        /// <example>
        ///     Very important switch, allowing to hide not so often used values.
        ///     CodeList can contain all 180 countries,
        ///     but only few frequently used will be displayed in comboboxes ...
        /// </example>
        /// </summary>
        public virtual bool IsVisible { get; set; }

        #region override abstract

        /// <summary>Description is used</summary>
        public override string ToDisplay()
        {
            return Description;
        }

        /// <summary>
        ///     Code must be unique for the ICodeList entity
        /// </summary>
        //protected override string GetDomainObjectSignature()
        //{
        //    return Description;
        //}

        /// <summary>
        ///     Code must be unique for the ICodeList entity
        /// </summary>
        protected override string GetDomainObjectSignature()
        {
            return Code;
        }

        #endregion override abstract
    }
}